/*
 * #%L
 * SwiftUIDataAccessLayer
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2011 - 2012 Linkwithweb
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */
package com.linkwithweb.products.swiftui.rowmapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.linkwithweb.products.swiftui.dataobject.FrameworkFormField;

/**
DROP TABLE IF EXISTS `automata`.`frm_form_fields`;
CREATE TABLE  `automata`.`frm_form_fields` (
  `FIELD_KEY` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `FIELD_ID` varchar(45) DEFAULT NULL,
  `FIELD_NAME` varchar(45) DEFAULT NULL,
  `FORM_ID` varchar(45) DEFAULT NULL,
  `FIELD_DESCRIPTION` varchar(45) DEFAULT NULL,
  `FIELD_LABEL` varchar(45) DEFAULT NULL,
  `FIELD_DEFAULT_VALUE` varchar(45) DEFAULT NULL,
  `FIELD_TYPE` varchar(45) DEFAULT NULL,
  `FIELD_FORMULAE` varchar(45) DEFAULT NULL,
  `EDITABLE` tinyint(1) NOT NULL,
  `DISPLAYABLE` tinyint(1) NOT NULL,
  `TRUE_VALUE` varchar(45) DEFAULT NULL,
  `FALSE_VALUE` varchar(45) DEFAULT NULL,
  `REF_TABLE_ID` varchar(45) DEFAULT NULL,
  `REF_TABLE_KEY_COLUMN` varchar(45) DEFAULT NULL,
  `REF_TABLE_VALUE_COLUMN` varchar(45) DEFAULT NULL,
  `FIELD_DEFAULT_FORMAT` varchar(45) DEFAULT NULL,
  `IS_ACTIVE` tinyint(1) NOT NULL,
  `IDENTIFIER` varchar(45) DEFAULT NULL,
  `IDENTIFIER_ROLE` varchar(45) DEFAULT NULL,
  `CREATED_BY` int(10) unsigned NOT NULL,
  `CREATED_DATE` datetime NOT NULL,
  `MODIFIED_BY` int(10) unsigned NOT NULL,
  `MODIFIED_DATE` datetime NOT NULL,
  `FIELD_COLSPAN` int(10) unsigned NOT NULL DEFAULT '1' COMMENT 'Defines how many columns this field spans..',
  DISPLAY_ORDER INT(10)
  PRIMARY KEY (`FIELD_KEY`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 * 
 *  This Class
 * Loads FormFields
 * 
 * @author ashwin
 * 
 */
public class FormFieldRowMapper extends AbstractRowMapper  {

	public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
		FrameworkFormField formField = new FrameworkFormField();
		formField.setDisplayable(rs.getBoolean("DISPLAYABLE"));
		formField.setEditable(rs.getBoolean("EDITABLE"));
		formField.setFalseValue(rs.getString("FALSE_VALUE"));
		formField.setFieldColspan(rs.getInt("FIELD_COLSPAN"));
		formField.setFieldDefaultFormat(rs.getString("FIELD_DEFAULT_FORMAT"));
		formField.setFieldDefaultValue(rs.getString("FIELD_DEFAULT_VALUE"));
		formField.setFieldDescription(rs.getString("FIELD_DESCRIPTION"));
		formField.setFieldFormulae(rs.getString("FIELD_FORMULAE"));
		formField.setFieldName(rs.getString("FIELD_NAME"));
		formField.setFieldId(rs.getString("FIELD_ID"));
		formField.setFieldKey(rs.getLong("FIELD_KEY"));
		formField.setFieldLabel(rs.getString("FIELD_LABEL"));
		formField.setFieldType(rs.getString("FIELD_TYPE"));
		formField.setFormId(rs.getString("FORM_ID"));
		formField.setRefTableId(rs.getString("REF_TABLE_ID"));
		formField.setRefTableKeyColumn(rs.getString("REF_TABLE_KEY_COLUMN"));
		formField.setRefTableValueColumn(rs.getString("REF_TABLE_VALUE_COLUMN"));
		formField.setTrueValue(rs.getString("TRUE_VALUE"));
		formField.setDisplayOrder(rs.getInt("DISPLAY_ORDER"));
		
		return mapDefaultColumns(formField,rs);
	}

}